package proto;

import java.awt.Color;

/**
 * @author Bitjaeger
 *
 */
public class Door extends Field {
    private int remainingKeys;
    private Level level;

    public Door(){
        color = Color.ORANGE;
    }
    /**
    * Overridden method for door-specific action.
    *
    * Complete level if all keys have been collected.
    */
    @Override
    public void DoAction(Stickman stickman) {
        super.DoAction(stickman);
        remainingKeys -= stickman.GetKeysCollected();
        if (remainingKeys == 0)
            level.SetComplete();
    }

    @Override
    public void Leave(){
        color = Color.ORANGE;
    }

    public void Init(int nkeys, Level level){
        remainingKeys = nkeys;
        this.level = level;
    }

}